//
//  TCVideoEditBGMHelper.h
//  TXXiaoShiPinDemo
//
//  Created by linkzhzhu on 2017/12/7.
//  Copyright © 2017年 tencent. All rights reserved.
//

#import <Foundation/Foundation.h>

#define BGM_DEBUG 1

#define BGMLog(...) {\
if(BGM_DEBUG)NSLog(__VA_ARGS__);\
}

@interface TCBGMElement : MHObject
//@property NSString* name;
//@property NSString* netUrl;
//
//@property NSString* author;
//@property NSString* title;
//@property NSNumber* duration;//float MicroSeconds
//@property NSNumber* isValid;

@property NSString* title;
@property NSString* localUrl;
@property NSNumber* isValid;
@property (nonatomic, strong) NSString * artists;
@property (nonatomic, assign) NSInteger autoId;
@property (nonatomic, assign) NSInteger categoryId;
@property (nonatomic, strong) NSString * categoryName;
@property (nonatomic, strong) NSString * code;
@property (nonatomic, strong) NSString * coverUrl;
@property(nonatomic, copy) NSString *fullCoverUrl;
@property (nonatomic, strong) NSString * created;
@property (nonatomic, assign) NSInteger downCount;
@property (nonatomic, strong) NSString * fullSongUrl;
@property (nonatomic, assign) BOOL isHaveCollect;
@property (nonatomic, strong) NSString * size;
@property (nonatomic, strong) NSString * songUrl;
@property (nonatomic, strong) NSString * timeLength;
@property (nonatomic, assign) NSInteger userId;
@property(nonatomic, strong) UIImage *image;
@property(nonatomic, assign) BOOL dataFromLocal;
@property(nonatomic, strong) NSURL *musicUrl;

-(BOOL) isCacheInLocal;
@end

@protocol TCBGMHelperListener <NSObject>

/**
 从json文件创建BGM列表，失败dict返回nil
 */
@required
-(void) onBGMListLoad:(NSDictionary*)dict;

/**
 每首BGM的进度回调
 */
@optional
-(void) onBGMDownloading:(TCBGMElement*)current percent:(float)percent;

/**
 下载结束回调，失败current返回nil
 */
@optional
-(void) onBGMDownloadDone:(TCBGMElement*)element;



@end


@interface TCBGMHelper : NSObject

@property(nonatomic)NSMutableDictionary* bgmDict;

-(void) setDelegate:(nonnull id<TCBGMHelperListener>) delegate;

//-(void) initBGMListWithJsonFile:(NSString* _Nonnull)url;
//-(void) loadBGMListFormRemoteWithPageNum:(int) pageNum pageSize:(int) pageSize finishBlock:(VoidBlock_id) finshBlock errBlock:(VoidBlock) errBlock;

+ (instancetype)sharedInstance;

/**
 下载BGM
新任务->新下载
当前正在下载->暂停下载
当前暂停->恢复下载
当前下载完成->重新下载

 @param name BGM名称
 */
-(void) downloadBGM:(TCBGMElement*) name;

-(void) loadBGMListFormRemoteWithPageNum:(int) pageNum pageSize:(int) pageSize finishBlock:(VoidBlock_id) finshBlock errBlock:(VoidBlock) errBlock;

-(NSArray *) loadLocalMusic;

//-(void) pauseAllTasks;
//
//-(void) resumeAllTasks;
@end
